home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / inventor / soundspheres / PlayClass.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  4.5 KB  |  113 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #ifndef PLAYCLASS_H
  18. #define PLAYCLASS_H
  19.  
  20. #include <audio.h>
  21. #include <audiofile.h>
  22.  
  23. class PlayClass;
  24.  
  25. typedef void PlayClassCB(void *data, PlayClass *pc);
  26.  
  27. class PlayClass {
  28.  
  29.   private:
  30.     int   init_audio(AFfilehandle, ALport *, ALconfig *);
  31.     int   play_audio_samps(AFfilehandle , ALport, ALconfig);
  32.     static void  go(void *);
  33.  
  34.     int  audio_pid;
  35.     int  caught_sigint;
  36.     int  paused;
  37.     long filefmt;         /* input file format */
  38.     int  fd;          /* input file descriptor */
  39.     char *myname;      /* name of this program */
  40.     int verbose, rude, quiet; /* global flags */
  41.     int bytes_per_samp;      /* sample width */
  42.     long bits_per_samp;         /* sample resolution */
  43.     int samps_per_frame;      /* frame size */
  44.     int frames_per_sec;      /* sample rate */
  45.     int bytes_per_buf;            /* bytes per sample buffer */
  46.     int samps_per_buf;            /* samples per sample buffer */
  47.     int frames_per_buf;           /* frames per sample buffer */
  48.     double secs_per_frame;     /* time it takes to play one audio frame */
  49.     double secs_per_buf;       /* time it takes to play one sample buffer */
  50.     char *sampbuf;                /* the sample buffer */
  51.     long compression;          /* audio data compression type */
  52.     double file_rate;          /* audio file sample rate */
  53.     char  *filename;
  54.     PlayClassCB  *doneCallback;
  55.     void         *userData;
  56.     short sproced;
  57.     short NoDone;              /* do I lie about being done? */
  58.  
  59. //    ALconfig audio_port_config;
  60.  
  61.     void attenuatesamps(void *, long, long, double, double,
  62.             double *, double, int);
  63.     short loop;
  64.     short fading_in;            /* while fading in */
  65.     short fading_out;            /* while fading out */
  66.     double in_time;            /* fade in time, sec */
  67.     double play_time;            /* play time, sec */
  68.     double out_time;            /* fade out time, sec */
  69.     double fade_level;            /* current fade_level */
  70.     double max_level;            /* maximum output level */    
  71.     double emitX, emitY, emitZ; /* the x,y,z position of the emitter */
  72.     double recX, recY, recZ;    /* the x,y position of the receiver */
  73.     double distanceFactor;      /* this is a class variable for caching rsns */
  74.     short timed;                /* are we being timed */
  75.     short useDistance;          /* do we care about the distances */
  76.     short distanceChanged;      /* do we need to recompute the distance? */
  77.     short isLive;               /* is the child process still alive? */
  78.     short isDone;               /* are we done playing the audio */
  79.  
  80.   public:
  81.     PlayClass(char *);
  82.     ~PlayClass();
  83.     int   beginPlaying(); // begin playing but do not sproc
  84.     void setFilename(char *); // set the audio file name
  85.     void setVerbose(int); // print out what is happening
  86.     void setQuiet(int); // do not print out everything
  87.     void setRude(int); // change the hardware sampling rate
  88.     void setCallback(PlayClassCB *, void *);
  89.     int start(); // play the file
  90.     void fadeOut(); // fade out the audio using the fade out time
  91.                     // THIS DOES NOT KILL THE CHILD PROCESS
  92.     void stop(); // stop playing, kills the child process
  93.     void setLoop(short); // set if looping
  94.     void setTime(double); // play the whole thing for an amount of time
  95.     void setInTime(double); // set a fade in and amount of time
  96.     void setOutTime(double); // set a fade out and amount of time
  97.     void setMaxOutputLevel(double); // set the maximum output lvl betwn 0 and 1
  98.     void setNoDone(short);
  99.  
  100.     void setUseDistance(short);
  101.     short getUseDistance();
  102.     void setEmitterPosition(double, double, double);
  103.     void setReceiverPosition(double, double, double);
  104.  
  105.     void pause();    // pause the audio
  106.     void unpause();  // start again
  107.  
  108.     short getIsLive();  // returns true or FALSE if a stop is needed
  109.     short donep(); // returns if done playing the audio
  110. };
  111.  
  112. #endif
  113.